#ifndef GLOBALPARAMETER_H
#define GLOBALPARAMETER_H

#pragma once

#include "qstring.h"
#include "QTime"

namespace interface
{
enum InterfaceRequestEnum
{
    //basic functions
    LOGIN = 0,       //client login
    SERVICE_CHOOSE,  //choose services
    BOOK_CAR,        //book a car
    CHOOSE_CAR,      //choose a car
    CONFIRM_CAR,    // user confirms the car he is selecting
    WAITING_FOR_CAR,  //wait for a car
    CAR_DRIVING,     //the car is taking the passenger
    ARRIVING,        //when the car arrvies at the point

    // other functions
    CAR_POOLING,    //car pooling
    FIXED_LOCATION_CALL_CAR, //fixed location to call the car
    ROUNTIN_SEARCH, //search for a rountin from one place to another
    LANDSCAPE_SEARCH,//search for a specific place
    CUSTOMER_SERVICES,//look for customer services

    // bus scheduler
    BUS_SCHEDULER_CHOOSE,
    BUS_SCHEDULER_SHOW
};
}

typedef struct
{
    QString name;
    QString id;
}CUSTOMER_NAME, *PCUSTOMER_NAME;

typedef struct
{
    QString car_id;
    // TODO: whether we should add the driver_id to identify which driver we are in touch with,
    // in case that multiple drivers drive one car.
    QString licence_number;
    QString driver_name;
    int arrivingTime;
    QString mobile_phone;
}CHOSEN_CAR_INFO, *PCHOSEN_CAR_INFO;

typedef struct
{
    CHOSEN_CAR_INFO * pCarInfo;
    QString order_id;
}ORDER_INFO, *PORDER_INFO;

#define ARRIVING_TIME_NUMBER 3

// struct used to show out the arrivingTime of a specified station
typedef struct
{
    QString busName; // the name of the bus
    QString directionFrom; // which direction the user will take? this indicates the from station name
    QString directionTo; // which direction the user will take? this indicates the end station name
    int     arrivingTimeForStart; // arriving time of the bus that reaches the start position. It will be just after the user's specified time
    int     arrivingTimeForEnd;// arriving time of the bus that reaches the end postion.
    int     howManyStationsInterval; // pass how many intervals?

    QString customerWantBeginStation;
    QString customerWantEndStation;
}BUS_INFO_FOR_OUT;

// struct used to show out all the necessary stations
typedef struct
{
    QString stationName;
    int arrivingTime; //arriving time from start to end, that is just after the user's specified time
    int arrivingTimeAnti; // arriving time from end to start, that is just after the user's specified time
}STATION_INFO_FOR_OUT;

// a struct that is used in the station-based hash table, which will help to find out
// the appropreate bus time and bus number for the specifed rountin.
struct BUS_INFO_STATION_BASED
{
    // a bus have two directions, one is from begin station to the last one, while another is vice
    QString BeginPosition; // the start position of the bus
    QString EndPosition; // the end position of the bus

    QString busName; // the name of the bus
    int interval; // the interval that this bus will arrive the next time

    int seqStartToEnd; //this station is the (idStartToEnd)th one from the start to the end
    int firstStartTimeStartToEnd; //mins of the day, the first time when the bus passes this station
    int lastStartTimeStartToEnd; // mins of the day, the last time when the bus passes this station

    int seqEndToStart; //this station is the (idStartToEnd)th one from the end to the start
    int firstStartTimeEndToStart; //mins of the day, the first time when the bus passes this station
    int lastStartTimeEndToStart; // mins of the day, the last time when the bus passes this station

    BUS_INFO_STATION_BASED(QString beginStation, QString endStation,\
                      QString busName, int interval,\
                      int seqStartToEnd, int firstStartTimeStartToEnd, int lastStartTimeStartToEnd,\
                      int seqEndToStart, int firstStartTimeEndToStart, int lastStartTimeEndToStart)
    {
        this->BeginPosition = beginStation;
        this->busName = busName;
        this->EndPosition = endStation;
        this->firstStartTimeEndToStart = firstStartTimeEndToStart;
        this->firstStartTimeStartToEnd = firstStartTimeStartToEnd;
        this->seqEndToStart = seqEndToStart;
        this->seqStartToEnd = seqStartToEnd;
        this->interval = interval;
        this->lastStartTimeEndToStart = lastStartTimeEndToStart;
        this->lastStartTimeStartToEnd = lastStartTimeStartToEnd;
    }
};

// a struct indicating bus name as well as station time, which will help to find all the
// station information according to the specified expecting time
struct BUS_INFO_NAME_BASED
{
    QString busName;
    QString startStation;
    QString endStation;
    int interval;

    QString stationName;

    //start to end
    int firstTimeStart2End;
    int lastTimeStart2End;

    // end to start
    int firstTimeEnd2Start;
    int lastTimeEnd2Start;

    BUS_INFO_NAME_BASED(){}

    BUS_INFO_NAME_BASED(QString busName, QString startStation, QString endStation, \
                        QString stationName, int interval,\
                        int firstTimeS2E, int lastTimeS2E,\
                        int firstTimeE2S, int lastTimeE2S)
    {
        this->busName = busName;
        this->startStation = startStation;
        this->endStation = endStation;
        this->interval = interval;
        this->stationName = stationName;
        this->firstTimeEnd2Start = firstTimeE2S;
        this->lastTimeEnd2Start = lastTimeE2S;
        this->firstTimeStart2End = firstTimeS2E;
        this->lastTimeStart2End = lastTimeS2E;
    }
};

// parameters to pass in bus scheduler functions
struct BUS_SCHEDULER_ORDER
{
    int command_id; // if it is 1, meaning the request is for seeing bus info
                    // if it is 2, meaning the request is for station info

    QTime expectedTime;

    // for command_id == 1
    QString busName;
    QString busBeginStation;
    QString busEndStation;
    int interval;

    // for command_id == 2
    QString customerWantStartStation;
    QString customerWantEndStation;
};
#endif // GLOBALPARAMETER_H
